import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/layout' //布局页



Vue.use(VueRouter)

// 通用页面, 这里的配置不需要权限
export const constRouter = [
  {
      path: '/login',
      component: () => import('@/views/login/Login'),
      hidden: true //导航菜单忽略选项
  },
  {
      path: '',
      component: Layout, //应用布局页
      redirect: '/index',
      hidden: true,
  },
  {
      path: '/index',
      component: Layout, //应用布局页
      name: 'index',
      meta:{
          title: "首页", //导航菜单项标题
          icon: 'el-icon-s-home' //导航菜单图标
      },
      children: [
        {
          path: '',
          component: () => import('@/views/index/index.vue'),
          name: 'indexs',
          meta: {
            title: "工作台",
            icon: 'el-icon-s-home',
            roles: ['admin','jerry']
          }
        }
      ]
  }
]

// 动态路由 communication
export const asyncRoutes = [
  {
    path: '/article',
    component: Layout,
    redirect: '/article/index',
    meta:{
      title: "技术文档管理",
      icon: 'el-icon-cpu',
      hidden: false,
    },
    children: [
      {
        path: 'addArticle',
        component: () => import('@/views/technology/AddArticle.vue'),
        name: 'addArticle',
        meta: {
          title: "添加(编辑文章)",
          icon: 'el-icon-tickets',
          hidden: true,
          roles: ['admin','jerry'],
          
        }
      },
      {
        path: 'editArticle/:articleId',
        component: () => import('@/views/technology/EditArticle.vue'),
        name: 'editArticle',
        meta: {
          title: "添加(编辑文章)",
          icon: 'el-icon-tickets',
          hidden: true,
          roles: ['admin','jerry'],
          
        }
      },
      {
        path: 'onindex',
        component: () => import('@/views/technology/OnIndex.vue'),
        name: 'onindex',
        meta: {
          title: "文章列表",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'offindex',
        component: () => import('@/views/technology/OffIndex.vue'),
        name: 'offindex',
        meta: {
          title: "待开发",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'sort',
        component: () => import('@/views/technology/Sort.vue'),
        name: 'sort',
        meta: {
          title: "标签分类",
          icon: 'el-icon-collection-tag',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
    ]
  },
  {
    path: '/control',
    component: Layout,
    redirect: '/control/homeCooking',
    meta:{
      title: "美食记录",
      icon: 'el-icon-food',
      hidden: false,
    },
    children: [
      {
        path: 'homeCooking',
        component: () => import('@/views/food/KeyCode.vue'),
        name: 'homeCooking',
        meta: {
          title: "家常菜",
          icon: 'el-icon-tableware',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'addFood/:type',
        component: () => import('@/views/food/AddFood.vue'),
        name: 'addFood',
        meta: {
          title: "添加美食",
          icon: 'el-icon-tableware',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'editFood/:foodId',
        component: () => import('@/views/food/EditFood.vue'),
        name: 'addFood',
        meta: {
          title: "编辑美食",
          icon: 'el-icon-tableware',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'placard',
        component: () => import('@/views/food/Placard.vue'),
        name: 'placard',
        meta: {
          title: "糕点饮品",
          icon: 'el-icon-burger',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
    ]
  },
  {
    path: '/travel',
    component: Layout,
    redirect: '/travel/travelList',
    meta:{
      title: "旅游风景",
      icon: 'el-icon-camera-solid',
      hidden: false,
    },
    children: [
      {
        path: 'travelList',
        component: () => import('@/views/travel/TravelList.vue'),
        name: 'travelList',
        meta: {
          title: "游记列表",
          icon: 'el-icon-picture-outline-round',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'addTravel',
        component: () => import('@/views/travel/AddTravel.vue'),
        name: 'spike',
        meta: {
          title: "新增游记",
          icon: 'el-icon-message',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'editTravel/:travelId',
        component: () => import('@/views/travel/EditTravel.vue'),
        name: 'spike',
        meta: {
          title: "编辑游记",
          icon: 'el-icon-message',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      // {
        // path: 'produce',
        // component: () => import('@/views/travel/Produce.vue'),
        // name: 'produce',
        // meta: {
          // title: "相片管理",
          // icon: 'el-icon-message',
          // hidden: false,
          // roles: ['admin','jerry']
        // }
      // },
    ]
  },
  {
    path: '/album',
    component: Layout,
    redirect: '/album/albumList',
    meta:{
      title: "图片管理",
      icon: 'el-icon-s-help',
      hidden: false,
    },
    children: [
      {
        path: 'albumList',
        component: () => import('@/views/album/albumList.vue'),
        name: '相册列表',
        meta: {
          title: "相册列表",
          icon: 'el-icon-picture',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'addAlbum',
        component: () => import('@/views/album/addAlbum.vue'),
        name: '新增相册',
        meta: {
          title: "新增相册",
          icon: 'el-icon-picture',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'editAlbum/:albumId',
        component: () => import('@/views/album/editAlbum.vue'),
        name: '修改相册',
        meta: {
          title: "修改相册",
          icon: 'el-icon-message',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
    ]
  },
  {
    path: '/home',
    component: Layout,
    redirect: '/home/index',
    meta:{
      title: "个人中心",
      icon: 'el-icon-user-solid',
      hidden: false,
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/home/Index.vue'),
        name: 'homeindex',
        meta: {
          title: "个人设置",
          icon: 'el-icon-user-solid',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'Informationall',
        component: () => import('@/views/home/Informationall.vue'),
        name: '点评',
        meta: {
          title: "点评管理",
          icon: 'el-icon-s-comment',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'settingList',
        component: () => import('@/views/home/setting.vue'),
        name: '系统配置',
        meta: {
          title: "系统配置",
          icon: 'el-icon-setting',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'personSummary',
        component: () => import('@/views/home/personSummary.vue'),
        name: '个人总结',
        meta: {
          title: "个人总结",
          icon: 'el-icon-document',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'addSummary',
        component: () => import('@/views/home/summaryDetail.vue'),
        name: '新增总结',
        meta: {
          title: "新增总结",
          icon: 'el-icon-message-solid',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'editSummary/:summaryId',
        component: () => import('@/views/home/editSummaryDetail.vue'),
        name: '编辑个人总结',
        meta: {
          title: "编辑个人总结",
          icon: 'el-icon-message-solid',
          hidden: true,
          roles: ['admin','jerry']
        }
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: constRouter
})

export default router

